package com.ukao.pad.printer;

import android.hardware.usb.UsbDevice;
import android.hardware.usb.UsbManager;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.ukao.pad.R;
import com.ukao.pad.base.BaseActivity;
import com.ukao.pad.eventbus.MainEvent;
import com.ukao.pad.eventbus.MembershipCardEvent;
import com.ukao.pad.utils.DateUtils;
import com.ukao.pad.utils.L;
import com.ukao.pad.utils.T;
import com.ukao.pad.utils.Utils;

import java.util.HashMap;
import java.util.Map;

import static com.ukao.pad.eventbus.MainEvent.Message.print;


/**
 * Created by herego on 2017/6/26.
 */

public class PrinterConnTipActivitys extends BaseActivity {

    PrinterHelper mPrinterHelper = null;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPrinterHelper = PrinterHelper.getInstance();
        UsbDevice usbDevice = (UsbDevice) getIntent().getParcelableExtra(UsbManager.EXTRA_DEVICE);
        if(usbDevice != null) {
           L.i("FileName: "+ usbDevice.getDeviceName());
            L.i("ProductId: "+ usbDevice.getProductId());
            L.i("VendorId: "+ usbDevice.getVendorId());
            if(usbDevice.getVendorId() == 4611 && usbDevice.getProductId() == 370) {  /*TSC清单打印*/
                Map map = new HashMap();
                map.put(ARG_PARAM1, Utils.getContext().getResources().getString(R.string.receipt_code));
                map.put(ARG_PARAM2, Utils.getContext().getResources().getString(R.string.receipt_print));
                MainEvent.postHasData(print, map);
            }else if (usbDevice.getVendorId() == 34918 && usbDevice.getProductId() == 256) { /*小票清单打印*/
                Map  map=new HashMap();
                map.put(ARG_PARAM1,Utils.getContext().getResources().getString(R.string.detailed_code));
                map.put(ARG_PARAM2, Utils.getContext().getResources().getString(R.string.detailed_print));
                MainEvent.postHasData(print,map);

            }else if(usbDevice.getVendorId() == 4611 && usbDevice.getProductId() == 294){/*水洗*/
                Map  map=new HashMap();
                map.put(ARG_PARAM1, Utils.getContext().getResources().getString(R.string.wash_code));
                map.put(ARG_PARAM2, Utils.getContext().getResources().getString(R.string.wash_print));
                MainEvent.postHasData(print,map);

            }else if(usbDevice.getVendorId() == 4611 && usbDevice.getProductId() == 310) {/*TSC T-210E清单打印*/
                Map  map=new HashMap();
                map.put(ARG_PARAM1, getString(R.string.detailed));
                map.put(ARG_PARAM2, Utils.getContext().getResources().getString(R.string.receipt_print));
                MainEvent.postHasData(print,map);

            }
        }else{
            T.show("未检测到连接设备");
        }
        finish();


    }

    @Override
    protected void initView() {



    }


}
